home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist6.3 / gl_dev.idb / usr / share / src / OpenGL / demos / fadeflip / texture.h.z / texture.h
Encoding:
C/C++ Source or Header  |  1996-12-06  |  3.8 KB  |  141 lines

  1. #include <GL/glu.h>
  2. #include <GL/glx.h>
  3.  
  4. extern "C" {
  5. #include "myimage.h"
  6. };
  7.  
  8. #define DEFAULT_DISPLAY_TYPE        GL_UNSIGNED_BYTE
  9. #define DEFAULT_DISPLAY_FORMAT        GL_RGBA
  10. #define DEFAULT_ALIGNMENT        1
  11. #define DEFAULT_COMPONENTS        4
  12. #define DEFAULT_LEVEL            0
  13.  
  14. #define DEFAULT_ENVIRONMENT        GL_MODULATE
  15.  
  16. #define DEFAULT_MIN_FILTER        GL_LINEAR
  17. #define DEFAULT_MAX_FILTER        GL_LINEAR
  18.  
  19. class texture {
  20.  public:
  21.   texture();
  22.   ~texture();
  23.   
  24.   void open();
  25.  
  26.   void set_display_format(GLenum new_display_format);
  27.   GLenum get_display_format();
  28.  
  29.   void set_display_type(GLenum new_display_type);
  30.   GLenum get_display_type();
  31.  
  32.   void set_alignment(int new_alignment);
  33.   int get_alignment();
  34.  
  35.   void set_components(int new_components);
  36.   int get_components();
  37.  
  38.   void set_level(int new_level);
  39.   int get_level();
  40.  
  41.   void set_environment(GLenum new_environment);
  42.   GLenum get_environment();
  43.  
  44.   void set_min_filter(GLenum new_min_filter);
  45.   GLenum get_min_filter();
  46.   void set_max_filter(GLenum new_max_filter);
  47.   GLenum get_max_filter();
  48.  
  49.   int get_width();
  50.   int get_height();
  51.  
  52.   void create_color(int total_size,
  53.             float r, float g, float b, float a, float l);
  54.   void create_checkerboard(int total_size, int block_size,
  55.                float r1 = 1.0, float g1 = 0.0, float b1 = 0.0,
  56.                float alpha1 = 1.0, float lum1 = 0.299,
  57.                float r2 = 0.0, float g2 = 0.0, float b2 = 1.0,
  58.                float alpha2 = 1.0, float lum2 = 0.114);
  59.   void create_diag_stripes(int total_size, int stripe_width,
  60.                float r1 = 1.0, float g1 = 0.0, float b1 = 0.0,
  61.                float alpha1 = 1.0, float lum1 = 0.299,
  62.                float r2 = 0.0, float g2 = 0.0, float b2 = 1.0,
  63.                float alpha2 = 1.0, float lum2 = 0.114);
  64.   void create_from_file(char *fname);
  65.  
  66.   void map_lum_to_alpha();
  67.  
  68.   void draw_pixels();
  69.   void draw_pixels(int x1, int y1, int x2, int y2);
  70.  
  71.   /* setup_texture() sets up the alignment etc */
  72.   void setup_texture();
  73.   void setup_texture(int x1, int y1, int x2, int y2);
  74.  
  75.   /* specify_texture():
  76.    * 1. Calls setup_texture()
  77.    * 2. Calls glTexImage2D() with a level of level if min_filter is 
  78.    * GL_NEAREST or GL_LINEAR, otherwise calls gluBuild2DMipmaps() */
  79.   void specify_texture();
  80.   void specify_texture(int x1, int y1, int x2, int y2);
  81.  
  82.   /* specify_mipmap()
  83.    * Calls glTexImage2D() with a level of level */
  84.   void specify_mipmap();
  85.   void specify_mipmap(int x1, int y1, int x2, int y2);
  86.  
  87.   void pixels_free();
  88.  
  89.  private:
  90.   void pixels_alloc();
  91.   void pixels_alloc(int size);
  92.  
  93.   void assign_pixel(int x, int y, float r, float g, float b, float a,
  94.             float l);
  95.   void assign_pixel(int x, int y, float r, float g, float b, float a,
  96.             float l, GLenum display_format,
  97.             GLenum display_type, int alignment);
  98.  
  99.   inline void assign_pixel_a(int x, int y, float a);
  100.  
  101.   void reformat(GLenum new_display_format, GLenum new_display_type,
  102.         int new_alignment);
  103.  
  104.   int row_length();
  105.   int row_length(GLenum display_format, GLenum display_type, 
  106.          int alignment);
  107.  
  108.   inline float pixel_r(int x, int y);
  109.   inline float pixel_r(int x, int y, GLenum display_format,
  110.                GLenum display_type, int alignment);
  111.  
  112.   inline float pixel_g(int x, int y);
  113.   inline float pixel_g(int x, int y, GLenum display_format,
  114.                GLenum display_type, int alignment);
  115.  
  116.   inline float pixel_b(int x, int y);
  117.   inline float pixel_b(int x, int y, GLenum display_format,
  118.                GLenum display_type, int alignment);
  119.  
  120.   inline float pixel_alpha(int x, int y);
  121.   inline float pixel_alpha(int x, int y, GLenum display_format,
  122.                GLenum display_type, int alignment);
  123.  
  124.   inline float pixel_lum(int x, int y);
  125.   inline float pixel_lum(int x, int y, GLenum display_format,
  126.              GLenum display_type, int alignment);
  127.  
  128.   int height, width;
  129.   GLvoid *pixels;
  130.   int pixels_size;
  131.   GLenum display_format;
  132.   GLenum display_type;
  133.   int alignment;
  134.   int components;
  135.   int level;
  136.  
  137.   GLenum environment;
  138.  
  139.   GLenum min_filter, max_filter;
  140. };
  141.